import { call, put } from 'redux-saga/effects';
import { userRegiter } from '../services/user';

export default {
  namespace: 'register',
  state: {
    userInfo: {},
    result: {},
  },
  effects: {
    *userRegite({ payload }) {
      const response = yield call(userRegiter, payload);
      yield put({
        type: 'register/dealRegisteResult',
        payload: { ...response },
      });
    },
  },
  reducers: {
    dealRegisteResult(state, action) {
      return {
        ...state,
        result: action.payload,
      };
    },
    clearResult(state) {
      return {
        ...state,
        result: {},
      };
    },
  },
};
